# -*- coding: utf-8 -*-
from sqlalchemy import Column, Integer, String, DateTime, func
import datetime
from utils.work_db import Base

# 月结类型
BalanceType = {
    1: 'month',
    2: 'week',
    3: 'day',
    4: 'other'
}
# 最低学历
# 0和7新增
EDU_DIC = {
    0: '不限',
    1: '高中及以下',
    2: '专科',
    3: '本科',
    4: '硕士',
    5: '博士及以上',
    6: '其他',
    7: '初中'
}
# 经验要求
EXP_REQ = [
    '不限',
    '一年',
    '2年',
    '3年',
    '5年及以上'
]
# 审核状态
AUDIT_STATUS = {
    '0': '待处理',
    '1': '通过',
    '2': '不适合'
}


# {name: '2000以下', code: 1},
# {name: '2000-4000', code: 2},
# {name: '4000-6000', code: 3},
# {name: '6000-8000', code: 4},
# {name: '8000-10000', code: 5},
# {name: '1万-2万', code: 6},
# {name: '2万以上', code: 7}

class Job(Base):
    __tablename__ = 'job'
    job_id = Column(Integer, primary_key=True, autoincrement=True)
    job_name = Column(String)
    # work_startdate = Column(String)
    # work_enddate = Column(String)
    # salary_lower = Column(String)
    # salary_upper = Column(String)
    # 职位状态(1:已发布 0：未发布 2:已过期 3:暂停)
    job_status = Column(Integer, default=0)
    salary_code = Column(Integer)
    job_time = Column(String)
    job_type = Column(Integer)
    job_place = Column(String)
    # 工作所需人数
    job_count = Column(Integer)
    job_content = Column(String, default='')
    job_requirement = Column(String, default='')
    job_remark = Column(String)
    job_cycle = Column(String)
    company_id = Column(Integer)
    # 职位发布来源(1:公司 2:个人)
    pub_from = Column(Integer, default=1)
    tel = Column(String)
    job_enddate = Column(String)
    create_userid = Column(Integer)
    create_time = Column(DateTime, default=func.now())
    update_time = Column(DateTime, default=func.now())
    province_code = Column(String)
    city_code = Column(String)
    # 结薪类型(1:月结 2:周结 3:日结 4:其他)
    balance_type = Column(Integer, default=4)
    job_class = Column(String)
    job_class_name = Column(String)
    # 岗位代码
    job_post = Column(String)
    # 岗位名称
    job_post_name = Column(String)
    country_code = Column(String)
    edu_code = Column(Integer)
    exp_req = Column(String)
    j_uuid = Column(String)
    audit_time = Column(DateTime, default=datetime.datetime.now())
    # 审核状态(0:待处理 1:通过 2:暂停)
    audit_status = Column(Integer, default=1)
    audit_msg = Column(String)
    audit_userid = Column(Integer)
    # 兼职薪资
    part_salary = Column(String)
    # 20190201新增
    # 员工福利 五险一金
    welfare = Column(String)
    # 年龄要求30~45岁
    age_req = Column(String)
    # 性别要求 男 女 不限
    sex_req = Column(String)
    # 附加要求
    attach_req = Column(String)

    def json(self):
        return {
            "job_id": self.job_id,
            "job_name": self.job_name,
            "job_status": self.job_status,
            "salary_code": self.salary_code if self.salary_code else '',
            "part_salary": self.part_salary if self.part_salary else '',
            "job_time": self.job_time if self.job_time else '',
            "job_type": self.job_type,
            "job_class": self.job_class,
            "job_class_name": self.job_class_name,
            "job_post_name": self.job_post_name,
            "job_post": self.job_post if self.job_post else '',
            "job_place": self.job_place if self.job_place else '',
            "job_count": self.job_count,
            "job_content": self.job_content if self.job_content else '',
            "job_requirement": self.job_requirement if self.job_requirement else '',
            "job_cycle": self.job_cycle if self.job_cycle else '',
            "company_id": self.company_id,
            "tel": self.tel if self.tel else '',
            "province_code": self.province_code,
            "city_code": self.city_code,
            "balance_type": self.balance_type,
            "country_code": self.country_code,
            "exp_req": self.exp_req if self.exp_req else '',
            "audit_status": self.audit_status,
            "welfare": self.welfare if self.welfare else '',
            "age_req": self.age_req if self.age_req else '',
            "sex_req": self.sex_req if self.sex_req else '',
            "attach_req": self.attach_req if self.attach_req else ''
        }
